package com.cn.customer.housekeeping.housekeepingb.ui;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.cn.customer.housekeeping.housekeepingb.R;
import com.cn.customer.housekeeping.housekeepingb.bean.BaseResp;
import com.cn.customer.housekeeping.housekeepingb.constant.Constants;
import com.cn.customer.housekeeping.housekeepingb.ui.adapter.ItemTitlePagerAdapter;
import com.cn.customer.housekeeping.housekeepingb.ui.base.BaseFragmentActivity;
import com.cn.customer.housekeeping.housekeepingb.ui.fragment.GoodsDetailWebFragment;
import com.cn.customer.housekeeping.housekeepingb.ui.fragment.OrderServiceFragment;
import com.cn.customer.housekeeping.housekeepingb.util.ToastUtil;
import com.cn.customer.housekeeping.housekeepingb.view.NoScrollViewPager;
import com.gxz.PagerSlidingTabStrip;

import java.util.ArrayList;
import java.util.List;

/***
 * 订单详情
 */
public class OrderDetailsActivity extends BaseFragmentActivity implements View.OnClickListener {
    public PagerSlidingTabStrip psts_tabs;
    public NoScrollViewPager vp_content;
    public TextView tv_title;
    private ImageView iv_top_backs;
    private List<Fragment> fragmentList = new ArrayList<>();
    private OrderServiceFragment goodsInfoFragment;
    private GoodsDetailWebFragment goodsDetailFragment;
    private GoodsDetailWebFragment goodsCommentFragment;
    private String serviceid;
    public GoodsDetailWebFragment mGoodsDetailWebFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_orderdetalis);
        super.onCreate(savedInstanceState);
    }

    @Override
    public void initViews() {
        psts_tabs = (PagerSlidingTabStrip) findViewById(R.id.psts_tabs);
        vp_content = (NoScrollViewPager) findViewById(R.id.vp_content);
        tv_title = (TextView) findViewById(R.id.tv_title);
        iv_top_backs = (ImageView) findViewById(R.id.iv_top_backs);
    }

    @Override
    public void initListeners() {
        iv_top_backs.setOnClickListener(this);
    }



    @Override
    public void initData() {
        serviceid = getIntent().getExtras().getString(Constants.serviceid);
        ToastUtil.makeText(OrderDetailsActivity.this,"serviceid:"+serviceid);
        mGoodsDetailWebFragment = new GoodsDetailWebFragment().newInstance("");

        fragmentList.add(new OrderServiceFragment().newInstance(serviceid));
        fragmentList.add(mGoodsDetailWebFragment);
        fragmentList.add(new GoodsDetailWebFragment().newInstance(""));
        vp_content.setAdapter(new ItemTitlePagerAdapter(getSupportFragmentManager(),
                fragmentList, new String[]{"服务", "详情", "评价"}));
        vp_content.setOffscreenPageLimit(3);
        psts_tabs.setViewPager(vp_content);
    }

    @Override
    public void onError(BaseResp s) {

    }

    @Override
    public void onSuccess(BaseResp s) {

    }

    @Override
    public void setHeader() {
        super.setHeader();
        rlTitle.setVisibility(View.GONE);

    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_top_backs:
                finish();
                break;


        }
        super.onClick(v);
    }

}
